From fd758aaa3c619ed1f3058117b55e61a3b59f8a63 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Thu, 2 Sep 2004 01:29:18 +0000 Subject: [PATCH] Big change to the skin system. Php files are now in ./skins/ . Templates and stylesheets will be migrated there as well later. The main idea is to let users add new skins easily without hacking mediawiki --- includes/Skin.php | 8 +- includes/SkinPHPTal.php | 39 ------ includes/User.php | 32 ++--- skins/Chick.php | 14 ++ skins/CologneBlue.php | 274 ++++++++++++++++++++++++++++++++++++++++ skins/DaVinci.php | 11 ++ skins/Mono.php | 11 ++ skins/MonoBook.php | 11 ++ skins/MySkin.php | 11 ++ skins/Nostalgia.php | 89 +++++++++++++ skins/Standard.php | 65 ++++++++++ skins/WikimediaWiki.php | 77 +++++++++++ 12 files changed, 577 insertions(+), 65 deletions(-) create mode 100644 skins/Chick.php create mode 100644 skins/CologneBlue.php create mode 100644 skins/DaVinci.php create mode 100644 skins/Mono.php create mode 100644 skins/MonoBook.php create mode 100644 skins/MySkin.php create mode 100644 skins/Nostalgia.php create mode 100644 skins/Standard.php create mode 100644 skins/WikimediaWiki.php diff --git a/includes/Skin.php b/includes/Skin.php index e6ded0a47c..3fc0b843a4 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -8,9 +8,9 @@ if( defined( "MEDIAWIKI" ) ) { require_once( 'Feed.php' ); // should not be called if the actual page isn't feed enabled require_once( 'Image.php' ); -# These are the INTERNAL names, which get mapped -# directly to class names. For display purposes, the -# Language class has internationalized names +# These are the INTERNAL names, which get mapped directly to class names and +# file names in ./skins/. For display purposes, the Language class has +# internationalized names # /* private */ $wgValidSkinNames = array( 'standard' => 'Standard', @@ -21,9 +21,9 @@ if( $wgUsePHPTal ) { #$wgValidSkinNames[] = 'PHPTal'; #$wgValidSkinNames['davinci'] = 'DaVinci'; #$wgValidSkinNames['mono'] = 'Mono'; + #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal'; $wgValidSkinNames['monobook'] = 'MonoBook'; $wgValidSkinNames['myskin'] = 'MySkin'; - #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal'; $wgValidSkinNames['chick'] = 'Chick'; } diff --git a/includes/SkinPHPTal.php b/includes/SkinPHPTal.php index 7400562cb4..dc2272947c 100644 --- a/includes/SkinPHPTal.php +++ b/includes/SkinPHPTal.php @@ -615,44 +615,5 @@ class SkinPHPTal extends Skin { } } -class SkinDaVinci extends SkinPHPTal { - function initPage( &$out ) { - SkinPHPTal::initPage( $out ); - $this->skinname = 'davinci'; - } -} - -class SkinMono extends SkinPHPTal { - function initPage( &$out ) { - SkinPHPTal::initPage( $out ); - $this->skinname = 'mono'; - } -} - -class SkinMonoBook extends SkinPHPTal { - function initPage( &$out ) { - SkinPHPTal::initPage( $out ); - $this->skinname = 'monobook'; - } -} - -class SkinMySkin extends SkinPHPTal { - function initPage( &$out ) { - SkinPHPTal::initPage( $out ); - $this->skinname = 'myskin'; - } -} - -class SkinChick extends SkinPHPTal { - function initPage( &$out ) { - SkinPHPTal::initPage( $out ); - $this->skinname = 'chick'; - $this->template = 'xhtml_minimal'; - } - function suppressUrlExpansion() { return true; } - function printSource() { return ''; } -} - - } // end of if( defined( 'MEDIAWIKI' ) ) ?> diff --git a/includes/User.php b/includes/User.php index 7c3fb2f95c..9e37b01f97 100644 --- a/includes/User.php +++ b/includes/User.php @@ -435,6 +435,7 @@ class User { } function &getSkin() { + global $IP; if ( ! isset( $this->mSkin ) ) { # get all skin names available from SkinNames.php $skinNames = Skin::getSkinNames(); @@ -445,41 +446,28 @@ class User { if ( !isset( $skinNames[$userSkin] ) ) { # in case the user skin could not be found find a replacement $fallback = array( - 0 => 'SkinStandard', - 1 => 'SkinNostalgia', - 2 => 'SkinCologneBlue'); + 0 => 'Standard', + 1 => 'Nostalgia', + 2 => 'CologneBlue'); # if phptal is enabled we should have monobook skin that superseed # the good old SkinStandard. if ( isset( $skinNames['monobook'] ) ) { - $fallback[0] = 'SkinMonoBook'; + $fallback[0] = 'MonoBook'; } if(is_numeric($userSkin) && isset( $fallback[$userSkin]) ){ $sn = $fallback[$userSkin]; } else { - $sn = 'SkinStandard'; + $sn = 'Standard'; } } else { # The user skin is available - $sn = 'Skin' . $skinNames[$userSkin]; + $sn = $skinNames[$userSkin]; } - # only require the needed stuff - switch($sn) { - case 'SkinMonoBook': - require_once( 'SkinPHPTal.php' ); - break; - case 'SkinStandard': - require_once( 'SkinStandard.php' ); - break; - case 'SkinNostalgia': - require_once( 'SkinNostalgia.php' ); - break; - case 'SkinCologneBlue': - require_once( 'SkinCologneBlue.php' ); - break; - } - # now we can create the skin object + # Grab the skin class and initialise it + require_once( $IP.'/skins/'.$sn.'.php' ); + $sn = 'Skin'.$sn; $this->mSkin = new $sn; } return $this->mSkin; diff --git a/skins/Chick.php b/skins/Chick.php new file mode 100644 index 0000000000..db7ad68b63 --- /dev/null +++ b/skins/Chick.php @@ -0,0 +1,14 @@ +skinname = 'chick'; + $this->template = 'xhtml_minimal'; + } + function suppressUrlExpansion() { return true; } + function printSource() { return ''; } +} + +?> diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php new file mode 100644 index 0000000000..b2f99aa275 --- /dev/null +++ b/skins/CologneBlue.php @@ -0,0 +1,274 @@ +qbSetting(); + $mainPageObj = Title::newMainPage(); + + $s .= "\n
\n
" . + ""; + + $s .= "
"; + $s .= "escapeLocalURL() . "\">"; + $s .= "" . wfMsg( "sitetitle" ) . ""; + + $s .= ""; + $s .= $this->sysLinks(); + $s .= "
"; + + $s .= ""; + $s .= htmlspecialchars( wfMsg( "sitesubtitle" ) ) . ""; + $s .= "" ; + + $s .= "" ; + $s .= str_replace ( "
" , "" , $this->otherLanguages() ); + $cat = $this->getCategoryLinks(); + if( $cat ) $s .= "
$cat\n"; + $s .= "
" . $this->pageTitleLinks(); + $s .= "
"; + + $s .= "
\n"; + + $s .= "\n
\n
"; + + if( $wgSiteNotice ) { + $s .= "\n
$wgSiteNotice
\n"; + } + $s .= $this->pageTitle(); + $s .= $this->pageSubtitle() . "\n"; + return $s; + } + + function doAfterContent() + { + global $wgUser, $wgOut; + + $s = "\n

\n"; + + $s .= "\n\n
\n"; + + if ( 0 != $qb ) { $s .= $this->quickBar(); } + return $s; + } + function doGetUserStyles() + { + global $wgUser, $wgOut, $wgStyleSheetPath; + $s = ''; + $qb = $this->qbSetting(); + + if ( 2 == $qb ) { # Right + $s .= "#quickbar { position: absolute; right: 4px; }\n" . + "#article { margin-left: 4px; margin-right: 148px; }\n"; + } else if ( 1 == $qb ) { + $s .= "#quickbar { position: absolute; left: 4px; }\n" . + "#article { margin-left: 148px; margin-right: 4px; }\n"; + } else if ( 3 == $qb ) { # Floating + $s .= "#quickbar { position:absolute; left:4px } \n" . + "#topbar { margin-left: 148px }\n" . + "#article { margin-left:148px; margin-right: 4px; } \n" . + "body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto ;bottom:4px;} \n"; # Hides from IE + } + $s .= parent::doGetUserStyles(); + return $s; + } + function sysLinks() + { + global $wgUser, $wgLang, $wgTitle; + $li = $wgLang->specialPage("Userlogin"); + $lo = $wgLang->specialPage("Userlogout"); + + $rt = $wgTitle->getPrefixedURL(); + if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) { + $q = ""; + } else { + $q = "returnto={$rt}"; + } + + $s = "" . + $this->makeKnownLink( wfMsg( "mainpage" ), wfMsg( "mainpage" ) ) + . " | " . + $this->makeKnownLink( wfMsg( "aboutpage" ), wfMsg( "about" ) ) + . " | " . + $this->makeKnownLink( wfMsg( "helppage" ), wfMsg( "help" ) ) + . " | " . + $this->makeKnownLink( wfMsg( "faqpage" ), wfMsg("faq") ) + . " | " . + $this->specialLink( "specialpages" ) . " | "; + + if ( $wgUser->getID() ) + { + $s .= $this->makeKnownLink( $lo, wfMsg( "logout" ), $q ); + } + else + { + $s .= $this->makeKnownLink( $li, wfMsg( "login" ), $q ); + } + + return $s; + } + + function quickBar() + { + global $wgOut, $wgTitle, $wgUser, $wgLang, $wgDisableUploads; + + $tns=$wgTitle->getNamespace(); + + $s = "\n
"; + + $sep = "
"; + $s .= $this->menuHead( "qbfind" ); + $s .= $this->searchForm(); + + $s .= $this->menuHead( "qbbrowse" ) + . $this->mainPageLink() + . $sep . $this->specialLink( "recentchanges" ) + . $sep . $this->specialLink( "randompage" ); + if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ; + $s .= "\n"; + + if ( $wgOut->isArticle() ) { + $s .= $this->menuHead( "qbedit" ); + $s .= "" . $this->editThisPage() . ""; + + $s .= $sep . $this->makeKnownLink( wfMsg( "edithelppage" ), wfMsg( "edithelp" ) ); + + if ( 0 != $wgUser->getID() ) { + $s .= $sep . $this->moveThisPage(); + } + if ( $wgUser->isSysop() ) { + $dtp = $this->deleteThisPage(); + if ( "" != $dtp ) { + $s .= $sep . $dtp; + } + $ptp = $this->protectThisPage(); + if ( "" != $ptp ) { + $s .= $sep . $ptp; + } + } + $s .= $sep; + + $s .= $this->menuHead( "qbpageoptions" ); + $s .= $this->talkLink() + . $sep . $this->commentLink() + . $sep . $this->printableLink(); + if ( 0 != $wgUser->getID() ) { + $s .= $sep . $this->watchThisPage(); + } + + $s .= $sep; + + $s .= $this->menuHead("qbpageinfo") + . $this->historyLink() + . $sep . $this->whatLinksHere() + . $sep . $this->watchPageLinksLink(); + + if ( Namespace::getUser() == $tns || Namespace::getTalk(Namespace::getUser()) == $tns ) { + $id=User::idFromName($wgTitle->getText()); + if ($id != 0) { + $s .= $sep . $this->userContribsLink(); + if ( 0 != $wgUser->getID() ) { + $s .= $sep . $this->emailUserLink(); + } + } + } + $s .= $sep; + } + + $s .= $this->menuHead( "qbmyoptions" ); + if ( 0 != $wgUser->getID() ) { + $name = $wgUser->getName(); + $tl = $this->makeKnownLink( $wgLang->getNsText( + Namespace::getTalk( Namespace::getUser() ) ) . ":{$name}", + wfMsg( "mytalk" ) ); + if ( 0 != $wgUser->getNewtalk() ) { $tl .= " *"; } + + $s .= $this->makeKnownLink( $wgLang->getNsText( + Namespace::getUser() ) . ":{$name}", wfMsg( "mypage" ) ) + . $sep . $tl + . $sep . $this->specialLink( "watchlist" ) + . $sep . $this->makeKnownLink( $wgLang->specialPage( "Contributions" ), + wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) ) + . $sep . $this->specialLink( "preferences" ) + . $sep . $this->specialLink( "userlogout" ); + } else { + $s .= $this->specialLink( "userlogin" ); + } + + $s .= $this->menuHead( "qbspecialpages" ) + . $this->specialLink( "newpages" ) + . $sep . $this->specialLink( "imagelist" ) + . $sep . $this->specialLink( "statistics" ) + . $sep . $this->bugReportsLink(); + if ( 0 != $wgUser->getID() && !$wgDisableUploads ) { + $s .= $sep . $this->specialLink( "upload" ); + } + global $wgSiteSupportPage; + if( $wgSiteSupportPage) { + $s .= $sep."" + .wfMsg( "sitesupport" ).""; + } + + $s .= $sep . $this->makeKnownLink( $wgLang->specialPage( "Specialpages" ), wfMsg("moredotdotdot") ); + + $s .= $sep . "\n
\n"; + return $s; + } + + function menuHead( $key ) + { + $s = "\n
" . wfMsg( $key ) . "
"; + return $s; + } + + function searchForm( $label = "" ) + { + global $wgRequest; + + $search = $wgRequest->getText( 'search' ); + $action = $this->escapeSearchLink(); + $s = "
"; + if ( "" != $label ) { $s .= "{$label}: "; } + + $s .= "" + . "
"; + + return $s; + } +} + +?> diff --git a/skins/DaVinci.php b/skins/DaVinci.php new file mode 100644 index 0000000000..34889944d1 --- /dev/null +++ b/skins/DaVinci.php @@ -0,0 +1,11 @@ +skinname = 'davinci'; + } +} +?> diff --git a/skins/Mono.php b/skins/Mono.php new file mode 100644 index 0000000000..91371f7cea --- /dev/null +++ b/skins/Mono.php @@ -0,0 +1,11 @@ +skinname = 'mono'; + } +} +?> diff --git a/skins/MonoBook.php b/skins/MonoBook.php new file mode 100644 index 0000000000..124675be2a --- /dev/null +++ b/skins/MonoBook.php @@ -0,0 +1,11 @@ +skinname = 'monobook'; + } +} + +?> diff --git a/skins/MySkin.php b/skins/MySkin.php new file mode 100644 index 0000000000..d6c155dae8 --- /dev/null +++ b/skins/MySkin.php @@ -0,0 +1,11 @@ +skinname = 'myskin'; + } +} +?> diff --git a/skins/Nostalgia.php b/skins/Nostalgia.php new file mode 100644 index 0000000000..301bbf0338 --- /dev/null +++ b/skins/Nostalgia.php @@ -0,0 +1,89 @@ +\n
"; + $s .= $this->logoText( "right" ); + + $s .= $this->pageTitle(); + $s .= $this->pageSubtitle() . "\n"; + + $s .= $this->topLinks() . "\n
"; + if( $wgSiteNotice ) { + $s .= "\n
$wgSiteNotice
\n"; + } + $s .= $this->pageTitleLinks(); + + $ol = $this->otherLanguages(); + if($ol) $s .= "
" . $ol; + + $cat = $this->getCategoryLinks(); + if($cat) $s .= "
" . $cat; + + $s .= "

\n
\n"; + $s .= "\n
"; + + return $s; + } + + function topLinks() + { + global $wgOut, $wgUser; + $sep = " |\n"; + + $s = $this->mainPageLink() . $sep + . $this->specialLink( "recentchanges" ); + + if ( $wgOut->isArticle() ) { + $s .= $sep . $this->editThisPage() + . $sep . $this->historyLink(); + } + if ( 0 == $wgUser->getID() ) { + $s .= $sep . $this->specialLink( "userlogin" ); + } else { + $s .= $sep . $this->specialLink( "userlogout" ); + } + $s .= $sep . $this->specialPagesList(); + + return $s; + } + + function doAfterContent() + { + global $wgUser, $wgOut; + + $s = "\n

\n"; + + $s .= "\n\n\n"; + + return $s; + } +} + +?> diff --git a/skins/Standard.php b/skins/Standard.php new file mode 100644 index 0000000000..ba367a370d --- /dev/null +++ b/skins/Standard.php @@ -0,0 +1,65 @@ +qbSetting() ) { # Floating left + $s .= "\n"; + } + return $s; + } + + function getUserStyles() + { + global $wgStylePath; + $s = ''; + if ( 3 == $this->qbSetting() ) { # Floating left + $s .= "\n"; + } + $s .= parent::getUserStyles(); + return $s; + } + + function doGetUserStyles() + { + global $wgUser, $wgOut, $wgStylePath; + + $s = parent::doGetUserStyles(); + $qb = $this->qbSetting(); + + if ( 2 == $qb ) { # Right + $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " . + "border-left: 2px solid #000000; }\n" . + "#article { margin-left: 4px; margin-right: 152px; }\n"; + } else if ( 1 == $qb || 3 == $qb ) { + $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " . + "border-right: 1px solid gray; }\n" . + "#article { margin-left: 152px; margin-right: 4px; }\n"; + } + return $s; + } + + function getBodyOptions() + { + $a = parent::getBodyOptions(); + + if ( 3 == $this->qbSetting() ) { # Floating left + $qb = "setup(\"quickbar\")"; + if($a["onload"]) { + $a["onload"] .= ";$qb"; + } else { + $a["onload"] = $qb; + } + } + return $a; + } +} + +?> diff --git a/skins/WikimediaWiki.php b/skins/WikimediaWiki.php new file mode 100644 index 0000000000..2d316cce91 --- /dev/null +++ b/skins/WikimediaWiki.php @@ -0,0 +1,77 @@ +skinname = "wikimediawiki"; + $this->template = "xhtml_slim_wikimediawiki"; + } + + # build array of common navigation links + function buildNavUrls () { + global $wgTitle, $wgUser, $wgRequest; + global $wgSiteSupportPage; + + $action = $wgRequest->getText( 'action' ); + $oldid = $wgRequest->getVal( 'oldid' ); + $diff = $wgRequest->getVal( 'diff' ); + // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes + $nav_urls = array(); + $nav_urls['mainpage'] = array('href' => htmlspecialchars( $this->makeI18nUrl('mainpage'))); + $nav_urls['randompage'] = (wfMsg('randompage') != '-') ? array('href' => htmlspecialchars( $this->makeSpecialUrl('Randompage'))) : false; + $nav_urls['recentchanges'] = (wfMsg('recentchanges') != '-') ? array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchanges'))) : false; + $nav_urls['whatlinkshere'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage )))); + $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('currentevents'))) : false; + $nav_urls['portal'] = (wfMsg('portal') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('portal-url'))) : false; + $nav_urls['recentchangeslinked'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage )))); + $nav_urls['bugreports'] = (wfMsg('bugreports') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('bugreportspage'))) : false; + $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $wgSiteSupportPage)); + $nav_urls['help'] = array('href' => htmlspecialchars( $this->makeI18nUrl('helppage'))); + $nav_urls['upload'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Upload'))); + $nav_urls['specialpages'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Specialpages'))); + + + # Specific for mediawiki.org menu + $nav_urls['aboutmediawiki'] = (wfMsg('aboutmediawiki') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('aboutmediawiki-url'))) : false; + $nav_urls['projects'] = (wfMsg('projects') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('projects-url'))) : false; + $nav_urls['membership'] = (wfMsg('membership') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('membership-url'))) : false; + $nav_urls['pressroom'] = (wfMsg('pressroom') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('pressroom-url'))) : false; + $nav_urls['software'] = (wfMsg('software') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('software-url'))) : false; + $nav_urls['localchapters'] = (wfMsg('localchapters') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('localchapters-url'))) : false; + $nav_urls['contactus'] = (wfMsg('contactus') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('contactus-url'))) : false; + + if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) { + $id = User::idFromName($wgTitle->getText()); + $ip = User::isIP($wgTitle->getText()); + } else { + $id = 0; + $ip = false; + } + + if ( 0 != $wgUser->getID() ) { # show only to signed in users + if($id) { + # can only email non-anons + $nav_urls['emailuser'] = array( + 'href' => htmlspecialchars( $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() ) ) + ); + # only non-anons have contrib list + $nav_urls['contributions'] = array( + 'href' => htmlspecialchars( $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() ) ) + ); + } + } + + + return $nav_urls; + } +} + + +?> -- 2.20.1